import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class Client extends Thread {

    private Client() {
        
    }

    public static void main(String[] args) {

	String serverHost = (args.length < 2) ? null : args[0];
	String systemAppName = (args.length < 2) ? args[0] : args[1];
        
	try {

	    Registry registry = LocateRegistry.getRegistry(serverHost);
	    ClientDS clientDS = (ClientDS) registry.lookup("ClientDS");
            
            int response = clientDS.getApp(systemAppName);

            String ipServer = clientDS.getIP();
	    System.out.println("\nServer answer: " + systemAppName + 
                    " has available bandwidth of " + response + " on "
                    + "host server " + ipServer + "\n");
	} catch (Exception e) {
	    System.err.println("Client exception: " + e.toString());
	    e.printStackTrace();
	}
    }
}